package pers.vic.blog.module.api.task.job;

import org.quartz.*;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.time.LocalTime;

/**
 * @author Vic.xu
 * @description:
 * @date: 2020/9/3 0003 15:10
 */
@Component
@DisallowConcurrentExecution
public class TestJob extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        JobDetail jobDetail = context.getJobDetail();
        JobDataMap map = jobDetail.getJobDataMap();
        // 任务的具体逻辑
        System.out.println("into TestJob: [key=" + jobDetail.getKey() + "] at " + LocalTime.now() + "   data => " );
        map.forEach((k,v)->{
            System.out.println("\t" + k + " ->" + v);
        });
    }
}
